.\"
.\"	$OpenBSD: SSL_CTX_set_max_cert_list.3,v 1.2 2014/12/02 14:11:01 jmc Exp $
.\"
.Dd $Mdocdate: December 2 2014 $
.Dt SSL_CTX_SET_MAX_CERT_LIST 3
.Os
.Sh NAME
.Nm SSL_CTX_set_max_cert_list ,
.Nm SSL_CTX_get_max_cert_list ,
.Nm SSL_set_max_cert_list ,
.Nm SSL_get_max_cert_list
.Nd manipulate allowed size for the peer's certificate chain
.Sh SYNOPSIS
.In openssl/ssl.h
.Ft long
.Fn SSL_CTX_set_max_cert_list "SSL_CTX *ctx" "long size"
.Ft long
.Fn SSL_CTX_get_max_cert_list "SSL_CTX *ctx"
.Ft long
.Fn SSL_set_max_cert_list "SSL *ssl" "long size"
.Ft long
.Fn SSL_get_max_cert_list "SSL *ctx"
.Sh DESCRIPTION
.Fn SSL_CTX_set_max_cert_list
sets the maximum size allowed for the peer's certificate chain for all
.Vt SSL
objects created from
.Fa ctx
to be
.Fa size
bytes.
The
.Vt SSL
objects inherit the setting valid for
.Fa ctx
at the time
.Xr SSL_new 3
is being called.
.Pp
.Fn SSL_CTX_get_max_cert_list
returns the currently set maximum size for
.Fa ctx .
.Pp
.Fn SSL_set_max_cert_list
sets the maximum size allowed for the peer's certificate chain for
.Fa ssl
to be
.Fa size
bytes.
This setting stays valid until a new value is set.
.Pp
.Fn SSL_get_max_cert_list
returns the currently set maximum size for
.Fa ssl .
.Sh NOTES
During the handshake process, the peer may send a certificate chain.
The TLS/SSL standard does not give any maximum size of the certificate chain.
The OpenSSL library handles incoming data by a dynamically allocated buffer.
In order to prevent this buffer from growing without bound due to data
received from a faulty or malicious peer, a maximum size for the certificate
chain is set.
.Pp
The default value for the maximum certificate chain size is 100kB (30kB
on the 16bit DOS platform).
This should be sufficient for usual certificate chains
(OpenSSL's default maximum chain length is 10, see
.Xr SSL_CTX_set_verify 3 ,
and certificates without special extensions have a typical size of 1-2kB).
.Pp
For special applications it can be necessary to extend the maximum certificate
chain size allowed to be sent by the peer.
See for example the work on
.%T "Internet X.509 Public Key Infrastructure Proxy Certificate Profile"
and
.%T "TLS Delegation Protocol"
at
.Lk http://www.ietf.org/
and
.Lk http://www.globus.org/ .
.Pp
Under normal conditions it should never be necessary to set a value smaller
than the default, as the buffer is handled dynamically and only uses the
memory actually required by the data sent by the peer.
.Pp
If the maximum certificate chain size allowed is exceeded, the handshake will
fail with a
.Dv SSL_R_EXCESSIVE_MESSAGE_SIZE
error.
.Sh RETURN VALUES
.Fn SSL_CTX_set_max_cert_list
and
.Fn SSL_set_max_cert_list
return the previously set value.
.Pp
.Fn SSL_CTX_get_max_cert_list
and
.Fn SSL_get_max_cert_list
return the currently set value.
.Sh SEE ALSO
.Xr ssl 3 ,
.Xr SSL_CTX_set_verify 3 ,
.Xr SSL_new 3
.Sh HISTORY
.Fn SSL*_set/get_max_cert_list
were introduced in OpenSSL 0.9.7.
